"use strict";
var _createClass = function () {
    function t(n, e) {
        for (var i = 0; i < e.length; i++) {
            var t = e[i];
            t.enumerable = t.enumerable || !1, t.configurable = !0, "value" in t && (t.writable = !0), Object.defineProperty(n, t.key, t)
        }
    }

    return function (n, e, i) {
        return e && t(n.prototype, e), i && t(n, i), n
    }
}();

function _classCallCheck(n, e) {
    if (!(n instanceof e)) throw new TypeError("Cannot call a class as a function")
}

new (function () {
    function i() {
        _classCallCheck(this, i);
        var n = this, e = $(".bannerBox");
        this.index = 0, this.bom = e, this.bnnerImg = e.find(".bg"), this.bnnerNav = e.find(".btn"), this.t = setInterval(function () {
            return n.init()
        }, 5e3), this.mov(), this.queryCoupon(), this.queryArticle()
    }

    return _createClass(i, [{
        key: "init", value: function () {
            var n = this.bnnerNav.find("li").length - 1;
            this.bnnerImg.find("li").eq(this.index).addClass("active").siblings().removeClass("active"), this.bnnerNav.find("li").eq(this.index).addClass("hy-color-bg").siblings().removeClass("hy-color-bg"), this.index == n ? this.index = 0 : this.index++
        }
    }, {
        key: "mov", value: function () {
            var e = this;
            this.bnnerNav.on("mouseover", "li", function (n) {
                clearInterval(e.t), e.index = $(this).data("benner"), e.init()
            }), this.bnnerNav.on("mouseout", "li", function (n) {
                e.t = setInterval(function () {
                    return e.init()
                }, 3e3)
            })
        }
    }, {
        key: "queryCoupon", value: function () {
            Rui.request("post", "/api/web/coupon/getCouponList", {}, function (n) {
                var i = n.value, t = JSON.parse(localStorage.getItem("coupon") || "[]"), e = Rui.config().shopCode,
                    o = JSON.parse(localStorage.getItem("couponCode") || "[]"), a = $("#coupon_box");
                if (i.length) {
                    if ("7476808499516821" == e) {
                        a.html('<div class="coupon_warp">\n                        <div class="coupon_tilte">\n                            <p class="max_tilte">每日神券抢不停</p>\n                            <p class="min_tilte">仅限活动期间使用</p>\n                        </div>\n                </div>');
                        for (var c = a.find(".coupon_warp"), s = 0; s < i.length; s++) {
                            var l = "";
                            l = -1 < o.indexOf(i[s].couponCode) ? '<div class="coupon_warp_item">\n                            <div class="coupon_currency">￥</div>\n                            <div class="coupon_money">' + i[s].couponMoney + '</div>\n                            <div class="coupon_explain">\n                                <div class="coupon_full">满' + i[s].limitMoney + '可用</div>\n                                <div class="coupon_active">已领取</div>\n                            </div>\n                           </div>' : '<div class="coupon_warp_item">\n                            <div class="coupon_currency">￥</div>\n                            <div class="coupon_money">' + i[s].couponMoney + '</div>\n                            <div class="coupon_explain">\n                                <div class="coupon_full">满' + i[s].limitMoney + '可用</div>\n                                <div class="coupon_receive" index="' + s + '">立即抢></div>\n                            </div>\n                           </div>', c.append(l)
                        }
                    } else for (a.show(), s = 0; s < i.length; s++) {
                        var r = "立即领取", u = "coupon_receive";
                        -1 < o.indexOf(i[s].couponCode) && (r = "已领取", u = "coupon_active"), a.append('<div class="coupon-item">\n                            <div class="item-item1">\n                                <div class="item-money"><span class="font28">￥</span><span class="font64">' + i[s].couponMoney + '</span></div>\n                                <div class="item-bottom">满' + i[s].limitMoney + '元可用</div>\n                            </div>\n                            <div class="item-item2 ' + u + '" index="' + s + '">' + r + "</div>\n                        </div>")
                    }
                    a.on("click", ".coupon_receive", function () {
                        var n = $(this), e = n.attr("index");
                        t.push(i[e]), o.push(i[e].couponCode), localStorage.setItem("coupon", JSON.stringify(t)), localStorage.setItem("couponCode", JSON.stringify(o)), n.addClass("coupon_active").removeClass("coupon_receive").html("已领取"), layer.msg("领取成功")
                    })
                }
            })
        }
    }, {
        key: "queryArticle", value: function () {
            Rui.request("post", "/api/web/hdc/getHomePageArticles", {}, function (n) {
                var e = $("#home_article"), i = $("#new_article"), t = n.value.homeArtcile, o = n.value.newArtcile;
                t.forEach(function (n) {
                    e.append('  <a class="bt-cell-list bt-active" target="_blank"  href="https://www.ismei.net/huayu/' + n.articleId + '">\n                    <div class="bt-cell-img">\n                        <img src="' + n.img + '">\n                    </div>\n                    <div class="bt-cell-details">\n                        <p class="bt-details-title hy-color-active">' + n.articleTitle + '</p>\n                        <p class="bt-details-futitle hy-color-active">' + n.metaDesc + "</p>\n                    </div>\n                </a>")
                }), o.forEach(function (n, e) {
                    e < 10 && i.append(' <a href="https://www.ismei.net/huayu/' + n.articleId + '" target="_blank"  class="bt-cell-acrlist hy-color-active">' + n.articleTitle + "</a>")
                })
            })
        }
    }]), i
}());